package net.projecteuler.problem1;

public class SumaMultiples {
	
	public long suma1(int limit) {
		long result = 0;
		int i = 0;
		int step = 1;
		int step11 = 3;
		int l = limit - (3 + limit % 3);
		while(i <= l) {
			result += i;
			if(step == step11) {
				result = result + (3 * i + 6);
				i += 3;
				step11 += 4;
			}
			step ++;
			i += 3;
		}
		return (i >= limit) ? result - (i - 2) : result;
	}
	
	public long suma2(int limit) {
		long result = 0;
		int i = 0;
		while(i < limit) {
			if(i % 3 == 0 || i % 5 == 0) {
				result += i;
			}
			i++;
		}
		return result;
	}
}
